require('../less/login.less')
document.ready(function () {
    // 获取元素节点
    let btn = document.getElementById('btn')
    let telnum = document.getElementById('telnum'); //手机号
    let psd = document.getElementById('psd'); //密码
    let register = document.getElementById('register'); //账号注册
    // 注册事件
    btn.addEventListener('click', function () {
        let psdVal = psd.value; //输入密码值
        let telnumVal = telnum.value; //手机号的值
        window.$http.post('/users/login', {
            account: telnumVal,
            password: psdVal
        }, function (res) {
            if (res.status == 0) {
                let userData = res.data.user
                console.log(userData);
                window.localStorage.setItem('userData', JSON.stringify(userData))
                window.location.href = './homePage.html'
            } else if (res.status == 1) {
                alert(res.msg)
            }
        })




    })
    //点击账号注册页面跳转到注册页面
    register.addEventListener('click',function(){
window.location.href='./register.html'


    })


})